package com.huawei.appmarket.service.appdetail.view.card;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.huawei.appgallery.jsonkit.api.JsonBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailTextListBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailTextListBean.TextListItem;
import com.huawei.appmarket.service.settings.view.widget.EnterLayout;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import java.util.List;
import o.ckt;
import o.Logger;
import o.dof;
import o.drl;
import o.CollectCheck;
import o.ewm.e;
import o.ewm.h;
import o.ewm.j;

public class DetailTextListCard extends drl implements OnClickListener {
    private LinearLayout ʻ;
    private DetailTextListBean ʽ;
    private EnterLayout ॱॱ;

    public DetailTextListCard() {
        this.ॱ = 310;
    }

    public View ˊ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.ˊ = layoutInflater.inflate(h.ˊᐝ, null);
        this.ʻ = (LinearLayout) this.ˊ.findViewById(j.ˍˏ);
        return this.ˊ;
    }

    public boolean ˊ(List<JsonBean> list) {
        if (CollectCheck.isEmpty(list)) {
            return false;
        }
        this.ʽ = (DetailTextListBean) list.get(0);
        if (this.ʽ == null || CollectCheck.isEmpty(this.ʽ.ॱ()) || dof.ॱ(this.ʽ.ˊ())) {
            return false;
        }
        List ॱ = this.ʽ.ॱ();
        for (int i = 0; i < ॱ.size(); i++) {
            TextListItem textListItem = (TextListItem) ॱ.get(i);
            int ॱ2 = textListItem.ॱ();
            if (!(ॱ2 == 2 || ॱ2 == 3)) {
                View enterLayout = new EnterLayout(this.ʻ.getContext());
                enterLayout.setId(j.ʽٴ + i);
                enterLayout.setBackgroundResource(e.ᐨ);
                if (i == this.ʽ.ॱ().size() - 1) {
                    this.ॱॱ = enterLayout;
                }
                enterLayout.setTitle(textListItem.ˋ());
                if (dof.ॱ(textListItem.ˏ()) || textListItem.ˊ() == 1) {
                    enterLayout.setMemoVisibility(8);
                } else {
                    enterLayout.setMemoVisibility(0);
                    enterLayout.setMemo(textListItem.ˏ());
                }
                if (ॱ2 == 0) {
                    enterLayout.setArrorVisibility(8);
                } else {
                    enterLayout.setArrorVisibility(0);
                    enterLayout.setOnClickListener(new ckt(this));
                }
                this.ʻ.addView(enterLayout);
            }
        }
        return true;
    }

    public void onClick(View view) {
        if (view != null) {
            int size = this.ʽ.ॱ().size();
            int id = view.getId() - j.ʽٴ;
            if (id >= 0 && id < size) {
                TextListItem textListItem = (TextListItem) this.ʽ.ॱ().get(id);
                id = textListItem.ॱ();
                String ˏ = textListItem.ˏ();
                if (id == 1) {
                    ˊ((Activity) view.getContext(), ˏ);
                }
            }
        }
    }

    private void ˊ(Activity activity, String str) {
        if (!dof.ॱ(str)) {
            try {
                activity.startActivity(new Intent(ACTION.HWID_SCHEME_URL, Uri.parse(str)));
            } catch (Exception e) {
                Logger.ˋ("DetailTextListCard", " There is no browser." + e.toString());
            }
        }
    }

    public void ᐝ() {
        if (this.ॱॱ != null) {
            this.ॱॱ.setLastLineGone();
        }
    }
}
